package addconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type QiNiYun struct {
	AccessKey string
	SecretKey string
	Bucket    string
	Url       string
}

type Mysql struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
}
type Redis struct {
	Host     string
	Port     int
	Password string
	Database int
}
type AddConfig struct {
	Redis
	Mysql
	QiNiYun
}

var err error
var Config AddConfig

func Init() {
	viper.SetConfigFile("../addconfig/config.yaml")
	err = viper.ReadInConfig()
	if err != nil {
		panic(err)
	}
	fmt.Println("动态配置读取成功")
	err = viper.Unmarshal(&Config)
	if err != nil {
		panic(err)
	}
	fmt.Println(Config)
}
